package com.project.service.impl;

import com.project.entity.po.Duty;
import com.project.exception.ServiceException;
import com.project.mapper.DutyMapper;
import com.project.result.ResponseResult;
import com.project.result.ResultCode;
import com.project.service.DutyService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class DutyServiceImpl implements DutyService {
    @Resource
    DutyMapper dutyMapper;

    @Override
    public ResponseResult<List<Duty>> selectAllDuty() {
        List<Duty> list = dutyMapper.selectAllDuty();
        if(list.size() == 0){
            throw new ServiceException(ResultCode.ERROR);
        }
        return ResponseResult.success(list);
    }

    @Override
    public ResponseResult<List<Duty>> selectDutyByName(String name) {
        List<Duty> list = dutyMapper.selectDutyByName(name);
        if(list.size() == 0){
            throw new ServiceException(ResultCode.ERROR);
        }
        return ResponseResult.success(list);
    }
}
